package com.jcp.service.imple;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jcp.dao.EmeMapper;
import com.jcp.entity.ExceptionMessage;
import com.jcp.service.EmService;
import com.jcp.util.LayuiData;

import tk.mybatis.mapper.entity.Example;

@Service
public class EmServiceImp implements EmService{
    
	@Autowired
	private EmeMapper emeMapper;
	
	/**
	 * ��ҳģ����ѯ
	 */
	public  LayuiData<ExceptionMessage> selectEmByPageAndLike(int page,int pageSize,String strlike){
		PageHelper.startPage(page,pageSize);
		Example example=new Example(ExceptionMessage.class);
		example.createCriteria().andLike("carNumber", strlike+"%");
		
		List<ExceptionMessage> liste=emeMapper.selectByExample(example);
		
		System.out.println("liste:"+liste);
		PageInfo<ExceptionMessage> pageinfo=new PageInfo<ExceptionMessage>(liste);
		LayuiData<ExceptionMessage> layuiData=new LayuiData<>(0, "", (int)pageinfo.getTotal(), pageinfo.getList());
		System.out.println("pageinfo.getList():"+pageinfo.getList());
		
		return layuiData;
		
		
	}

	@Override
	public boolean adadEm(ExceptionMessage exm) {
		// TODO Auto-generated method stub
		int inser=emeMapper.insert(exm);
		System.out.println("flag:"+inser);
		return inser>0;
	}

	@Override
	public boolean updateEm(ExceptionMessage exm) {
		// TODO Auto-generated method stub
		int n=emeMapper.updateByPrimaryKeySelective(exm);
		return n>0;
	}
	
}
